const { DataTypes } = require("sequelize");

const seq = require("../db/seq");
const User = require("./user.model");

// 创建模型(Model zd_user -> 表 zd_users)
const Member = seq.define(
  "member",
  {
    // id 会被sequelize自动创建, 管理
    member_content: {
      type: DataTypes.TEXT,
      allowNull: false,
      comment: "会员申请备注",
    },
    user_id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "申请用户id",
    },
    status: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: "申请状态, 0: 申请中(默认); 1: 驳回； 2:统一",
    },
  },
  {
    paranoid: true,
  }
);
Member.belongsTo(User, {
  foreignKey: "user_id",
  as: "user_info",
});
// 强制同步数据库(创建数据表)
// Member.sync({ force: true });

module.exports = Member;
